package br.com.geropder.aspectos.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "UBA")
public class UBA implements Serializable {
	private static final long serialVersionUID = 1505027616683976561L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "uba_id")
	private long id;

	@OneToOne
	@JoinColumn(name = "regional_id")
	private Regional regional;

	@Column(name = "uba")
	private String uba;

	@Column(name = "uba_codigo")
	private String codigo;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Regional getRegional() {
		return regional;
	}

	public void setRegional(Regional regional) {
		this.regional = regional;
	}

	public String getUba() {
		return uba;
	}

	public void setUba(String uba) {
		this.uba = uba;
	}

	public String getCodigo() {
		return codigo;
	}

	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	@Override
	public String toString() {
		return "UBA [id=" + id + ", regional=" + regional + ", uba=" + uba
				+ ", codigo=" + codigo + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
		result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result
				+ ((regional == null) ? 0 : regional.hashCode());
		result = prime * result + ((uba == null) ? 0 : uba.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UBA other = (UBA) obj;
		if (codigo == null) {
			if (other.codigo != null)
				return false;
		} else if (!codigo.equals(other.codigo))
			return false;
		if (id != other.id)
			return false;
		if (regional == null) {
			if (other.regional != null)
				return false;
		} else if (!regional.equals(other.regional))
			return false;
		if (uba == null) {
			if (other.uba != null)
				return false;
		} else if (!uba.equals(other.uba))
			return false;
		return true;
	}
}